<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="{{asset('layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="{{asset('Jquery/jquery-3.3.1.js')}}"></script>
</head>
<body>
<script src="{{asset('layui/layui.js')}}"></script>
<form  class="layui-form" action="{{url('updateUser')}}" method="post">
    @csrf
    <input type="hidden" name="userId" value="{{$editUser->id}}">
    <table class="layui-table">
        <thead>
        <tr>
            <th colspan="4" style="font-size: 18px;text-align: center;color:#666666">编辑用户</th>
        </tr>

        <tr>
            <th style="text-align: center;color:#666666;font-size: 14px"><label>用户名:</label></th>
            <th colspan="3">
                <div>
                   {{$editUser->username}}
                </div>
                <div>
                    @if($errors->has('username'))
                        <span class="s3"><i class="red">*</i>  <sapn id="cellphone_point" style="color: red">{{$errors->first('username')}}</sapn></span>
                    @endif
                </div>
            </th>
        </tr>
        <tr>
            <th style="text-align: center;color:#666666;font-size: 14px"><label>真实姓名:</label></th>
            <th colspan="3">
                <div>
                    <input type="text" name="realname" required  value="{{$editUser->realname}}" lay-verify="required" placeholder="请输入用户真实姓名" autocomplete="off" class="layui-input" style="width:250px; height:30px;">
                </div>
                <div>
                    @if($errors->has('realname'))
                        <span class="s3"><i class="red">*</i>  <sapn id="cellphone_point" style="color: red">{{$errors->first('realname')}}</sapn></span>
                    @endif
                </div>
            </th>
        </tr>
        <tr>
            <th style="text-align: center;color:#666666;font-size: 14px">
                <label>手机号:</label>
            </th>
            <th colspan="3">
                <div>
                    <input type="text" name="cellphone" required  lay-verify="required" value="{{$editUser->cellphone}}" placeholder="由11位数字组成的中国大陆手机号" autocomplete="off" class="layui-input" style="width:280px; height:30px;" >
                </div>
                <div>
                    @if($errors->has('cellphone'))
                        <span class="s3"><i class="red">*</i>  <sapn id="cellphone_point" style="color: red">{{$errors->first('cellphone')}}</sapn></span>
                    @endif
                </div>
            </th>
        </tr>

        <tr>
            <th style="text-align: center;color:#666666;font-size: 14px"><label>新密码：</label></th>
            <th>
                <div>
                    <input type="password" name="password"   value=""  placeholder="由6-18位数字或字母组成，不修改可不填写" autocomplete="off" class="layui-input" style="width:280px; height:30px;" >
                </div>
                <div>
                    @if($errors->has('password'))
                        <span class="s3"><i class="red">*</i>  <sapn id="cellphone_point" style="color: red"></sapn></span>
                    @endif
                </div>
            </th>
        </tr>
        <tr>
            <th style="text-align: center;color:#666666;font-size: 14px"><label>确认密码：</label></th>
            <th>
                <div>
                    <input type="password" name="password_confirmation"   value=""  placeholder="请再次输入密码" autocomplete="off" class="layui-input" style="width:280px; height:30px;" >
                </div>
                <div>
                    @if($errors->has('password_confirmation'))
                        <span class="s3"><i class="red">*</i>  <sapn id="cellphone_point" style="color: red">{{$errors->first('password_confirmation')}}</sapn></span>
                    @endif
                </div>
            </th>
        </tr>

        <tr>
            <th colspan="4" style="color:deeppink;font-size: 25px;text-align: center">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="">确认编辑</button>
                    </div>
                </div>
            </th>
        </tr>
        </div>
        </thead>
    </table>
    <div class="layui-form-item"><input type="hidden" id="promptMessage" name="promptMessage" value="{{Session::get('status')}}"></div>
</form>
</div>
{{--添加成功后的提示信息--}}
<script>
    layui.use(['layer'],function(){
        var layer=layui.layer;
        var msg=$("#promptMessage").val();
        if(msg!=""){
            layer.msg(msg);
        }
    });
</script>
{{--监听--}}
<script>
    $(function () {
        layui.use('form', function () {
            var $ = layui.jquery;
            var form = layui.form; //Tab的切换功能，切换事件监听等，需要依赖element模块
            form.on('select()', function(data){
                $("#videoNum").empty();
                var videoId=$("#changeVideo option:selected").val()
                var url="{{url('getVideoNum')}}";
                $.ajax({
                    url:url,
                    type:'POST',
                    data:{'videoId':videoId,'_token':"{{csrf_token()}}"},
                    success:function(response){
                        $("#videoNum").empty();
                        $("#videoNum").append(response);


                    }

                });
            });

        });

    });

</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#test6'
            ,range: true
        });
    })
</script>
{{--视频上传--}}
<script>

    layui.use('upload', function(){
        var upload = layui.upload;
        /*视频上传*/
        $(function () {
            var uploadInst = upload.render({
                elem: '#videos' //绑定元素
                ,field:'vid'
                ,accept:'video'
                ,acceptMime:'video/mkv'
                ,exts:'mkv|avi|wmv|mp4|rmvb|3gp|mov|avm|flv|m4v'
                ,size:1024*1024*10
                ,url: '/api/uploadVideo' //上传接口
                ,before: function(obj){
                    layer.load();
                }
                ,done: function(res){
                    layer.closeAll('loading'); //关闭loading
                    if(res.msg==1){
                        layer.msg('小主，影片上传成功哦！', {icon: 6});
                        $("#vid_url").val(res.url);
                        $('#tipMsg').text('(成功)');
                    }
                    //上传完毕回调
                }
                ,error: function(error){
                    layer.closeAll('loading'); //关闭loading
                    //请求异常回调
                    if(error.msg==0){
                        layer.msg('小主，影片上传失败啦！', {icon: 2});
                        $('#tipMsg').text('(失败)');
                    }
                }
            });
        });
    });

</script>
</body>
</html>